﻿using KM.Framework.Utility;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;

namespace KM.Framework.Business
{

    public class KeyTextBox: TextBox
    {
      
        public KeyTextBox()
        {
            this.AddHandler(KeyTextBox.MouseLeftButtonUpEvent, new RoutedEventHandler(tb_MouseDown), true);
        }
        private void tb_MouseDown(object sender, RoutedEventArgs e)
        {
            KeyboardView keyView = new KeyboardView(this.Text.ToStringV1());
            keyView.Closed += (c, d) =>
            {
                if (keyView.DialogResult == true && !keyView.boxValue.IsNullOrEmptyOrWhiteSpace())
                {
                    this.Text = keyView.boxValue;
                }
                else
                {
                    return;
                }
            };
            keyView.ShowDialog();
        }
    }
}
